<?php

class metacritic
{
	
	protected $_baseUrl			= null;
	protected $_sheetUrl		= null;
	protected $_probe			= null;
	protected $_platforms 		= Array(); //platform supported in search list
	protected $_plat			= Array(); //platform searched
	protected $_coverUrl		= Array();
	
	protected $_proxyConfig = null;
	protected $_content   		= "";
	protected $_response  		= "";
	
	protected $_useProxy		= null;
	
	public function __construct(){
		$this->_useProxy = false;
	}
	
	public function useProxy($proxy){
		$this->_useProxy = $proxy;
	}
	
	public function setProxy($proxy){
		$this->_proxyConfig = $proxy;
	}
	
	public function setProbe($probe){
		$this->_probe = str_replace (" ","+",$probe);
		$this->_probe = str_replace ("-","+",$this->_probe);
		$this->_probe = str_replace ("_","+",$this->_probe);
	}
	
	public function setBaseUrl($url){
		$this->_baseUrl = $url;
	}
	
	public function setSheetUrl($url){
		$this->sheetUrl = $url;
	}
	
	public function setCoverUrl($url){
		$this->coverUrl = $url;
	}
	
	public function setPlatformsSupport($platforms){
		$this->_platforms = $platforms;
	}
	
	public function setPlatform($plat){
		$this->_plat = $plat;
	}
	
	protected function __urlGetContent($url){
		if ($this->_useProxy) {
			return file_get_contents($url, False, $this->_proxyConfig);
		}
		return file_get_contents ($url);	
	}
	
	function __getMyPlatform($str){
		//$platformsForList = array ('360'=>'xbox360','PS3'=>'ps3','NDS'=>'ds','3DS'=>'3ds','VITA'=>'vita','PSP'=>'psp','WII'=>'wii','PC'=>'pc','IOS'=>'ios');
		if (preg_match('/game\/playstation-3/is',$str)){
			return 'PS3';
		}
		if (preg_match('/game\/xbox/is',$str)){
			return '360';
		}
		if (preg_match('/game\/wii/is',$str)){
			return 'WII';
		}
		if (preg_match('/game\/psp/is',$str)){
			return 'PSP';
		}
		if (preg_match('/game\/ds/is',$str)){
			return 'NDS';
		}
		if (preg_match('/game\/3ds/is',$str)){
			return '3DS';
		}
		if (preg_match('/game\/pc/is',$str)){
			return 'PC';
		}
		if (preg_match('/game\/playstation-vita/is',$str)){
			return 'VITA';
		}
		if (preg_match('/game\/ios/is',$str)){
			return 'IOS';
		}
	}
	
}

?>